package tgc.edu.zz.controller;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import tgc.edu.zz.entity.UserEntity;
import tgc.edu.zz.service.UserService;

@Controller
@RequestMapping("/main")
public class UserController {

	@Autowired
	private UserService service;

	@RequestMapping("/findById")
	public void findById() {
		UserEntity model = service.findById(3);
		System.out.println("用户名："+model.getUsername()+",密码："+model.getPassword()+",姓名"+model.getName());
	}
	
	@RequestMapping("/findAll")
	public List<UserEntity> findAll(){
		List<UserEntity> list = service.findAll();
		for (UserEntity model : list) {
			System.out.println("用户名："+model.getUsername()+",密码："+model.getPassword()+",姓名"+model.getName());
		}
		return list;
	}
	
	@RequestMapping("/delete")
	public void delete() {
		service.delete(3);
	}
	
	@RequestMapping("/insert")
	public void insert() {
		UserEntity model = new UserEntity();
		model.setUsername("0055");
		model.setPassword("2323");
		model.setName("李三");
		service.insert(model);
	}
	
	
	@RequestMapping("/update")
	public void update() {
		UserEntity model = service.findById(3);
		model.setName("李四");
		service.update(model);
	}
	
	
	@RequestMapping("/jwd")
	@ResponseBody
	public void jwd(String carnumber,double x ,double y) {
		System.err.println(carnumber);
		System.err.println(x);
		System.err.println(y);
		
	}
}
